define(
		[ "PDAppDir/properties", "PDUtilDir/util", "PDUtilDir/tool", "PDUtilDir/slidebar", "PDUtilDir/inputSelect", "css!AppPathDir/order/orderInfos/views/css/css" ],
		function(Properties, Util, Tool, Slidebar, inputSelect) {
			function PaySupportInit($scope, $compile) {
				return new PaySupport($scope, $compile);
			}
			function PaySupport($scope, $compile) {
				this.$scope = $scope;
				this.$compile = $compile;
			}
			PaySupport.fn = PaySupport.prototype;
			PaySupport.fn.digest = function() {
				this.$scope.$digest();
			}
			PaySupport.fn.init = function(id) {
				var _this = this;
				_this.entity = {
					id: id,
					pays: new Array()
				};
				var dataArray = _this.$scope.grid.getAllData();
				$.each(dataArray, function(index, row) {
					if( id == row.id){
						_this.entity = $.extend(_this.entity, row);
						_this.entity.statusName = _this.$scope.cache.statusMap.get(_this.entity.status);
						_this.digest();
					}
				});
				_this.cache = {
					fileServer: Properties.URL_FILE_SERVER_URL,
					images: new Array()
				}
				_this.bind = {}
			}
			
			PaySupport.fn.run = function(data) {
				var _this = this;
				_this.init(data);
				this.slidebars = Slidebar({
					size : 'lg',
					url : getServer()
							+ "/static/app/group/guideGroupInfos/views/pay.html",
					$scope : this.$scope,
					$compile : this.$compile,
					afterLoad : function($Panel) {
						_this.initialization();
					}
				});
			};
			PaySupport.fn.initialization = function() {
				var _this = this;
				$.ajax({
					url : getServer() + "/flea/hclv/qr/manage/selectByGuideId.htmls",
					data : {
						guideId  : _this.entity.guideId
					},
					success : function(data) {
                        if (data.status != 200) {
                            return;
                        }
						data = data.data;

                        $.each(data, function(index, row) {
                            _this.cache.images.push({
                                type: row.type,
                                qrCodePath: row.qrCodePath
                            });
                        });
						// console.info(_this.cache.images);
						_this.digest();
					}
				});
				// 初始化支付类型下拉框
				inputSelect.dropCache();
				inputSelect({
					id : "payPlatformName",
					key : {
						id : "dictCode",
						name : "dictName",
						data : "data",
					},
					data : _this.$scope.cache.types,
					simpleData : true,
					searchAble : false,
					callback : function(id, obj) {
						_this.bind.payPlatform = id[0];
						_this.$scope.payGuideGroupForm.payPlatform.$setViewValue(_this.bind.payPlatform);
					}
				});
			};
			PaySupport.fn.save = function() {
				var _this = this, data = $.extend({
					id : _this.entity.id,
					travelGroupId : _this.entity.travelGroupId
				}, _this.bind);
				
				$.ajax({
					url : getServer() + "/flea/hclv/guide/payForGuide.htmls",
					data : {
						model: JSON.stringify(data)
					},
					success : function(data) {
                        if (data.status != 200) {
                            return;
                        }
						_this.$scope.grid.refresh();
						Util.alert(data.message);
						_this.slidebars.close();
					}
				});
			};
			return PaySupportInit;
		});